package com.book.service;/**
 * Created by CoolWen on 2017/4/28.
 */

import com.book.dao.ClassesMapper;
import com.book.entity.Classes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author yicheng
 * @version 2017-04-28 9:51
 */
@Service("ClassesService")
public class ClassesServiceImpl implements ClassesService {

    @Autowired
    ClassesMapper classesMapper;

    @Override
    public int addClasses(Classes classes) {
        return classesMapper.add(classes);
    }

    @Override
    public int updateClasses(Classes classes) {
        return classesMapper.update(classes);
    }

    @Override
    public int deleteClasses(Integer integer) {
        return classesMapper.delete(integer);
    }

    @Override
    public Classes loadClasses(Integer integer) {
        return classesMapper.load(integer);
    }

    @Override
    public List<Classes> find(String name) {
        Map<String, Object> params = new HashMap<String, Object>();
        if (name != null && !name.equals(""))
            params.put("name", "%" + name + "%");
        return classesMapper.find(params);
    }

    @Override
    public Classes loadClassesAndTeacher(Integer integer) {
        return classesMapper.loadByClasss(integer);
    }

    @Override
    public Classes loadClassesAndStudent(Integer integer) {
        return classesMapper.loadStudent(integer);
    }
}
